<?php
	$url=$_GET["host"];
	$u=parse_url($url);
	$host=$u['host'];	
	exec("ping -c 1 $host", $list);
	for($i=0;$i<count($list);$i++){
		if(preg_match('/Destination Host Unreachable/i', $list[$i], $matches)){
			echo '{"code":"0","times":"0","httpcode":"0"}';
		}else{
			if (preg_match('/time=(\d+.\d+)/i', $list[$i], $matches))
			{
				$time = $matches[1];
				echo '{"code":"1","times":"'.$time.'","httpcode":"2"}';
			}
		}
	}
?>
